<?php
header("Content-type: text/html; charset=utf-8");

require("conn.php");
$username=@$_POST['username'];

$password=@$_POST['password'];
$code=@$_POST['code'];
$shi4=time();
$b_time =strtotime('+12 Month',$shi4);
$shi5=date('Y-m-d H:i:s',$b_time);
$shi6=strtotime($shi5);
 $ipj=$_SERVER["REMOTE_ADDR"];
$password=md5($password);
if ($code!=$_SESSION["vcode"]) {
	echo "<script language='javascript'>alert('验证码错误！');window.location.href='login.php?lei=qq&a=reg';</script>";
}

		$result = @mysql_query("SELECT * FROM admin where hao='".$username."' and mi='".$password."' ");
				 $row = @mysql_fetch_array($result);
				  if(mysql_num_rows($result)>0){

if ($row['tai']==0) {
	echo "<script language='javascript'>alert('您的账号已被冻结，请联系管理员！');window.location.href='login.php?lei=qq&a=reg';</script>";
	return false;
}
	$result2 = @mysql_query("SELECT * FROM admin where hao='".$username."'  ");
				 $row2 = @mysql_fetch_array($result2);
				 $_COOKIE['bzuid'] = $row2["id"];
        $_COOKIE['uname'] = $row2["hao"];

		  setcookie("bzuid",$row2["id"],time()+12*4*7*24*3600);
	
			setcookie("uname",$row2["hao"],time()+12*4*7*24*3600);
	
		
	echo "<script language='javascript'>window.location.href='index.php?lei=qq&a=reg';</script>";
return false;
				  }else{
//sql="INSERT INTO tp_users(openid,uname,touxiang,validdays,createtime,lasttime,status,createip,lastip,viptime,ming) VALUES ('".$uopenid."','".$nickname."','".$figureurl."',365,'".time()."','".time()."',1,'".$ipj."','".$ipj."','".time()."','".$nickname."');";

	echo "<script language='javascript'>alert('帐号密码错误！');window.location.href='login.php?lei=qq&a=reg';</script>";

				  }
				  
				   ?>
	